using System;
using DG.Tweening;
using UnityEngine;

public class ShopButton : MonoBehaviour
{
	public ShopButtonState CurrentState = ShopButtonState.Hidden;

	public GameObject Notification;

	public Action OnClicked;

	public Action AnimationComplete;

	public Action AnimationStarted;

	public Vector2 ShowingSize;

	public Vector2 HiddinSize;

	public RectTransform thisRect;

	public void SwitchState(ShopButtonState newState)
	{
		if (newState == CurrentState)
		{
			return;
		}
		CurrentState = newState;
		AnimationStarted?.Invoke();
		if (CurrentState == ShopButtonState.Showing)
		{
			SwitchNotification(itemAvailable: false);
			thisRect.DOSizeDelta(ShowingSize, 0.5f, snapping: true).OnComplete(delegate
			{
				AnimationComplete?.Invoke();
			});
		}
		else
		{
			thisRect.DOSizeDelta(HiddinSize, 0.5f, snapping: true).OnComplete(delegate
			{
				AnimationComplete?.Invoke();
			});
		}
	}

	public virtual void SwitchNotification(bool itemAvailable)
	{
		if (Notification != null)
		{
			Notification.SetActive(itemAvailable);
		}
	}

	public void AnimationCompleted()
	{
		AnimationComplete?.Invoke();
	}

	public virtual void OnCLick()
	{
		SwitchState(ShopButtonState.Showing);
		OnClicked?.Invoke();
	}

	private void Start()
	{
	}

	private void Update()
	{
	}
}
